//
//  MLRefreshAndLazyLoadTableView.h
//  InventoryTool
//
//  Created by molon on 6/5/14.
//  Copyright (c) 2014 Molon. All rights reserved.
//

#import <UIKit/UIKit.h>


#define kLazyLoadPageSize 20

@class MLRefreshAndLazyLoadTableView,Model,ModelArray,MolonRequestHelper;
typedef MolonRequestHelper *(^MLRefreshAndLazyLoadTableViewCustomRequestHelperBlock)(MLRefreshAndLazyLoadTableView *tableView,BOOL isNextPage);

@interface MLRefreshAndLazyLoadTableView : UITableView<UITableViewDataSource,UITableViewDelegate>

@property (nonatomic, assign) BOOL isNeedDelete;

@property (nonatomic, weak) Class modelArrayClass;
@property (nonatomic, strong, readonly) ModelArray *data;

@property (nonatomic, assign, readonly) NSUInteger currentPageNo;
@property (nonatomic, assign, readonly) BOOL isReloading;
@property (nonatomic, weak, readonly) MolonRequestHelper *lastRequestHelper;


@property (nonatomic, copy) MLRefreshAndLazyLoadTableViewCustomRequestHelperBlock customRequestHelperBlock;

- (void)setCustomRequestHelperBlock:(MolonRequestHelper *(^)(MLRefreshAndLazyLoadTableView *tableView,BOOL isNextPage))block;

//需要继承的方法
- (Class)modelArrayClass;
- (MolonRequestHelper*)requestHelperForIsNextPage:(BOOL)isNextPage;
- (UITableViewCell*)customCellForRow:(NSUInteger)row;
- (CGFloat)customCellHeightForRow:(NSUInteger)row;
- (void)didSelectRow:(NSUInteger)row;
/**
 *  这个需要处理是否要回归条件，防止懒加载条件出错
 */
- (void)reloadFailed;

//主动调用的方法
- (void)validatePullDownToRefresh;
- (void)clearAndResetData;
- (void)doneSearchWithRequestHelper:(MolonRequestHelper*)requestHelper andResult:(ModelArray*)result andIsSuccess:(BOOL)isSuccess andIsLoadedAll:(BOOL)isLoadedAll;
//如果不激活下拉刷新，使用此方法初始载入数据
- (void)doReload;

@end
